package org.csu.gp_store.bo;


import lombok.Data;
import org.csu.gp_store.entity.OrderItem;
import org.csu.gp_store.entity.Orders;


import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@Data
public class OrdersBO {


    private String orderID;
    private String accountID;
    private String billAddress;
    private String billName;
    private String billPhone;
    private String billNotes;
    private BigDecimal totalAmount;
    private int status;
    private Timestamp addTime;
    private List<OrderItem> orderItemList;

    public  static OrdersBO toOrdersBO(Orders orders,List<OrderItem> orderItemList) {
        OrdersBO ordersBO=new OrdersBO();
        ordersBO.setOrderID(String.valueOf(orders.getOrderID()));
        ordersBO.setAccountID(String.valueOf(orders.getAccountID()));
        ordersBO.setBillAddress(orders.getBillAddress());
        ordersBO.setBillName(orders.getBillName());
        ordersBO.setBillPhone(orders.getBillPhone());
        ordersBO.setBillNotes(orders.getBillNotes());
        ordersBO.setTotalAmount(orders.getTotalAmount());
        ordersBO.setStatus(orders.getStatus());
        ordersBO.setAddTime(orders.getAddTime());
        ordersBO.setOrderItemList(orderItemList);
        return  ordersBO;
    }

    public  static OrdersBO toOrdersBO(Orders orders,OrderItem orderItem) {
        OrdersBO ordersBO=new OrdersBO();
        ordersBO.setOrderID(String.valueOf(orders.getOrderID()));
        ordersBO.setAccountID(String.valueOf(orders.getAccountID()));
        ordersBO.setBillAddress(orders.getBillAddress());
        ordersBO.setBillName(orders.getBillName());
        ordersBO.setBillPhone(orders.getBillPhone());
        ordersBO.setBillNotes(orders.getBillNotes());
        ordersBO.setTotalAmount(orders.getTotalAmount());
        ordersBO.setStatus(orders.getStatus());
        ordersBO.setAddTime(orders.getAddTime());
        List<OrderItem> orderItemList = new ArrayList<>();
        orderItemList.add(orderItem);
        ordersBO.setOrderItemList(orderItemList);
        return  ordersBO;
    }
}
